package com.example.logintest.dao;

import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.logintest.entity.BookInfo;

import java.util.List;

public interface BookDao {

    @Query("select * from BookInfo")
    List<BookInfo> getAllBook();

    @Query("select * from BookInfo where name=:name")
    BookInfo getBookByName(String name);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertOneBook(BookInfo bookInfo);

    @Insert
    void insertBookList(List<BookInfo> bookInfos);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    int updateBook(BookInfo bookInfo);

    @Delete
    void deleteBook(BookInfo bookInfo);

    @Query("delete from BookInfo where 1=1")
    void deleteAllBook();
}
